package inter;

/**
 * 接口回调
 */
public class HuiDIao {
    public static void main(String[] args) {
        //对学生对象排序
        Studernt[] students =new Studernt[]{
                new Studernt("ton",22,"男",99),
                new Studernt("kack",20,"男",98),
                new Studernt("her",25,"男",97),
                new Studernt("jay",21,"男",96),
        };
//java.util.Arrays.sort(studernts);
        //students[0].compareTo(students[1]);//编辑哦成绩,返回一个正数
        //接口的调用者
        Sort.sort(students);

        for (int i = 0; i <students.length ; i++) {
            System.out.println(students[i].name+"\t"+students[i].score);
        }
    }
}
//对学生对象排序
//接口实现者
class  Studernt implements  Comparable<Studernt>{
    String name;
    int age;
    String sex;
    double score;

    public Studernt() {
    }

    public Studernt(String name, int age, String sex, double score) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.score = score;
    }


    @Override
    public int compareTo(Studernt studernt) {
        if (this.score>studernt.score) {
            return 1;
        }else  if(this.score<studernt.score){
            return  -1;
        }
        return 0;
    }
}